import 'package:casdon/core/network/api_client_provider.dart';
import 'package:casdon/modules/recipe/application/notification/recipe_category_notifier.dart';
import 'package:casdon/modules/recipe/application/notification/recipe_module_content_notifier.dart';
import 'package:casdon/modules/recipe/application/notification/recipe_module_list_notifier.dart';
import 'package:casdon/modules/recipe/application/notification/recipe_today_list_notifier.dart';
import 'package:casdon/modules/recipe/application/notification/tab_controller_notifier.dart';
import 'package:casdon/modules/recipe/data/repository/recipe_repository_impl.dart';
import 'package:casdon/modules/recipe/domain/states/recipe_category_state.dart';
import 'package:casdon/modules/recipe/domain/states/recipe_module_content_state.dart';
import 'package:casdon/modules/recipe/domain/states/recipe_module_list_state.dart';
import 'package:casdon/modules/recipe/domain/states/recipe_today_list_state.dart';
import 'package:casdon/modules/recipe/domain/usecase/recipe_category_usecase.dart';
import 'package:casdon/modules/recipe/domain/states/tab_state.dart';
import 'package:casdon/modules/recipe/domain/usecase/recipe_module_content_usecase.dart';
import 'package:casdon/modules/recipe/domain/usecase/recipe_module_list_usecase.dart';
import 'package:casdon/modules/recipe/domain/usecase/recipe_today_list_usecase.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

// 全局Provider
final tabProvider = StateNotifierProvider<TabControllerNotifier, TabState>(
  (ref) => TabControllerNotifier(["收藏", "精选", "智能"]),
);

// 菜谱api仓库
final recipeRepository = Provider(
  (ref) => RecipeRepositoryImpl(apiClient: ref.read(apiClientProvider)),
);

// usecase
// 获取菜谱分类
final recipeCategoryUsecaseProvider = Provider(
  (ref) => RecipeCategoryUsecase(ref.read(recipeRepository)),
);
// 获取菜谱模块列表
final recipeModuleListUsecaseProvider = Provider(
  (ref) => RecipeModuleListUsecase(ref.read(recipeRepository)),
);
// 菜谱各个模块的内容列表：烹饪课程，菜谱集，活动等
final recipeModuleContentUsecaseProvider = Provider(
  (ref) => RecipeModuleContentUsecase(ref.read(recipeRepository)),
);
// 今日菜谱
final recipeTodayListUsecaseProvider = Provider(
  (ref) => RecipeTodayListUsecase(ref.read(recipeRepository)),
);

// notifional
// 菜谱分类
final recipeCategoryAsyncProvider =
    AsyncNotifierProvider<RecipeCategoryNotifier, RecipeCategoryState>(
      () => RecipeCategoryNotifier(),
    );

// 菜谱模块列表
final recipeModuleListAsyncProvider =
    AsyncNotifierProvider<RecipeModuleListNotifier, RecipeModuleListState>(
      () => RecipeModuleListNotifier(),
    );

// 菜谱模块内容，
final recipeModuleContentAsyncProvider =
    AsyncNotifierProviderFamily<
      RecipeModuleContentNotifier,
      RecipeModuleContentState,
      String
    >(() => RecipeModuleContentNotifier());

// 今日菜谱列表
final recipeTodayListAsyncProvider =
    AsyncNotifierProvider<RecipeTodayListNotifier, RecipeTodayListState>(
      () => RecipeTodayListNotifier(),
    );
